package com.example.test;

public class myClass {
    public static void main(String[] args) {
        long zhu = combination(22,6)*((long)2);
        System.out.println("-----------------------------");
        System.out.println(zhu);
    }
    /**
     * 计算组合数，即C(n, m) = n!/((n-m)! * m!)
     * n 个里面选 m 个  可以重复
     * @param n
     * @param m
     * @return
     */
    public static long combination(int n, int m) {
        return (n >= m) ? factorial(n) / factorial(n - m) / factorial(m) : 0;
    }
    /**
     * 计算阶乘数，即n! = n * (n-1) * ... * 2 * 1
     * @param n
     * @return
     */
    private static long factorial(int n) {
        return (n > 1) ? n * factorial(n - 1) : 1;
    }
}
